
package Vista;

import Control.Control;
import Handler.DragAndDrop;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;


public class HorarioAlternoConsultar1 extends javax.swing.JPanel {

    private Control control;
    private DragAndDrop dragAndDrop;
    JPopupMenu popupMenu = new JPopupMenu();
    private static String INSERT_CMD = "Eliminar";
  

    public HorarioAlternoConsultar1(Control pControl) {
        control = pControl;
        initComponents();
        jTable2.getColumnModel().getColumn(1).setPreferredWidth(100);
        jTable2.getColumnModel().getColumn(2).setPreferredWidth(100);
        jTable2.getColumnModel().getColumn(3).setPreferredWidth(100);
        jTable2.getColumnModel().getColumn(0).setPreferredWidth(50);
    
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane4 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();

        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"7:00-7:40", null, null, null, null, null},
                {"7:40-8:20", null, null, null, null, null},
                {"8:25-9:05", null, null, null, null, null},
                {"9:05-9:45", null, null, null, null, null},
                {"10:05-10:45", null, null, null, null, null},
                {"10:45-11:25", null, null, null, null, null},
                {"11:30-12:10", null, null, null, null, null},
                {"12:10-12:50", null, null, null, null, null},
                {"1:30-2:10", null, null, null, null, null},
                {"2:10-2:50", null, null, null, null, null},
                {"2:55-3:35", null, null, null, null, null},
                {"3:35-4:15", null, null, null, null, null},
                {"4:25-5:05", null, null, null, null, null},
                {"5:05-5:45", null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Horas", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.setSelectionBackground(new java.awt.Color(51, 204, 0));
        jScrollPane3.setViewportView(jTable2);
        if (jTable2.getColumnModel().getColumnCount() > 0) {
            jTable2.getColumnModel().getColumn(0).setPreferredWidth(2);
        }

        jPanel1.add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 50, 750, 280));

        jScrollPane4.setViewportView(jPanel1);

        add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 0, 1100, 550));
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    public javax.swing.JTable jTable2;
    // End of variables declaration//GEN-END:variables


   

  

  
    class PopupListener extends MouseAdapter {
    public void mousePressed(MouseEvent e) {
      showPopup(e);
    }

    public void mouseReleased(MouseEvent e) {
      showPopup(e);
    }

    private void showPopup(MouseEvent e) {
      if (e.isPopupTrigger()) {
        popupMenu.show(e.getComponent(), e.getX(), e.getY());
      }
    }
  }

  void eliminar(ActionEvent e) {
      //JOptionPane.showMessageDialog(null, "algo se jodio");
//     control.eliminarDeHorario(jTable2.getSelectedRow(), jTable2.getSelectedColumn(),this);
  }

  protected void processWindowEvent(WindowEvent e) {
    this.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }
  
  class InsertRowsActionAdapter implements ActionListener {
  HorarioAlternoConsultar1 adaptee;

  InsertRowsActionAdapter(HorarioAlternoConsultar1 adaptee) {
    this.adaptee = adaptee;
  }

  public void actionPerformed(ActionEvent e) {
    adaptee.eliminar(e);
  }
    }


}
